package cn.tedu.charging.common.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult<T> {
    private String message;
    private Integer code;
    private T data;
    public JsonResult(StatusCode statusCode){
        message=statusCode.getMessage();
        code=statusCode.getCode();
    }
    public JsonResult(StatusCode statusCode,T data){
        message=statusCode.getMessage();
        code=statusCode.getCode();
        this.data=data;
    }

    public static JsonResult success(){
       return JsonResult.success(null);
    }
    public static JsonResult success(Object data){
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }
}
